package view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import javax.swing.BoxLayout;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.WindowConstants;

import view.interfaces.IAddShapeThree;
import controller.ControllerAddShapeThree;
import controller.ControllerAddShapeTwo;
import controller.ControllerHome;

public class AddShapeThree extends AddShapeTwo implements IAddShapeThree {

	private static final long serialVersionUID = 1L;
	protected ControllerAddShapeThree thisController;
    protected static JTabbedPane ongletsDeNavigation;
    
    protected JFrame jFrame;
    protected JButton btnAddShapeOne;
    protected JComboBox<String> comboBoxShapesAvailable;
    
    protected JPanel panelChooseBorder, panelChooseWidth, panelChooseHeight, panelChoosePosX, panelChoosePosY, 
    panelChooseDepth;
    
    protected JTextField txtFieldWidth, txtFieldHeight,
    				   txtFieldPositionX, txtFieldPositionY,
    				   txtFieldBorderSize, txtFieldDepth;
    
    protected int positionX;
    protected int positionY;
    protected int width;
    protected int height;
    
    public AddShapeThree(ControllerAddShapeThree controller) {
    	
    	this(controller, -1, -1, -1, -1);
    	
    }
    
    public AddShapeThree(ControllerAddShapeThree controller, int posX, int posY) {
    	
    	this(controller, posX, posY, -1, -1);
    	
    }
    
    public AddShapeThree(ControllerAddShapeThree controller, int posX, int posY, int vWidth, int vHeight) {

    	super(new ControllerAddShapeTwo());
    	
        thisController = controller;
        thisController.setView(this);

        positionX = posX;
        positionY = posY;
        width = vWidth;
        height = vHeight;
        
        panelEmptyTwo.setLayout(new BoxLayout(panelEmptyTwo, BoxLayout.PAGE_AXIS));

        txtFieldWidth = new JTextField(20);
    	txtFieldDepth = new JTextField(20);
    	txtFieldHeight = new JTextField(20);
    	txtFieldPositionX = new JTextField(20);
    	txtFieldPositionY = new JTextField(20);
    	txtFieldBorderSize = new JTextField(20);
    	
    	panelChooseBorder = new JPanel(new FlowLayout());
    	panelChooseWidth = new JPanel(new FlowLayout());
    	panelChooseHeight = new JPanel(new FlowLayout());
    	panelChoosePosX = new JPanel(new FlowLayout());
    	panelChoosePosY = new JPanel(new FlowLayout());
    	panelChooseDepth = new JPanel(new FlowLayout());
    	

        comboBoxShapesAvailable = new JComboBox(ControllerHome.shapesAvailable);
        panelEmptyOne.add(comboBoxShapesAvailable);


		panelChooseBorder.add(new JLabel("Taille contour :"));
		panelChooseBorder.add(txtFieldBorderSize);
		txtFieldBorderSize.setText("0");
		
		panelChooseWidth.add(new JLabel("Largeur :"));
		panelChooseWidth.add(txtFieldWidth);
		txtFieldWidth.setText("0");
		
		panelChooseHeight.add(new JLabel("Hauteur :"));
		panelChooseHeight.add(txtFieldHeight);
		txtFieldHeight.setText("0");
		
		panelChoosePosX.add(new JLabel("Position X :"));
		panelChoosePosX.add(txtFieldPositionX);
		txtFieldPositionX.setText("0");
		
		panelChoosePosY.add(new JLabel("Position Y :"));
		panelChoosePosY.add(txtFieldPositionY);
		txtFieldPositionY.setText("0");
		
		panelChooseDepth.add(new JLabel("Profondeur :"));
		panelChooseDepth.add(txtFieldDepth);
		txtFieldDepth.setText("0");
		
		panelEmptyTwo.add(panelChooseBorder);
		panelEmptyTwo.add(panelChooseWidth);
		panelEmptyTwo.add(panelChooseHeight);
		panelEmptyTwo.add(panelChoosePosX);
		panelEmptyTwo.add(panelChoosePosY);
		panelEmptyTwo.add(panelChooseDepth);
		

    	if(positionX >= 0) txtFieldPositionX.setText(positionX+"");
    	if(positionY >= 0) txtFieldPositionY.setText(positionY+"");

    	if(width >= 0) txtFieldWidth.setText(width+"");
    	if(height >= 0) txtFieldHeight.setText(height+"");

        btnSend.addActionListener(thisController);
        btnSend.setActionCommand("SENDADDSHAPETHREE");
        
        setSize(400, 450);

    }
    
    public String getValueComboBoxShapesAvailable() {
    	
    	return (String) comboBoxShapesAvailable.getSelectedItem();
    	
    }

    public int getValueTxtFieldWidth() {
    	
    	return Integer.parseInt(txtFieldWidth.getText());
    	
    }
    
    public int getValueTxtFieldHeight() {
    	
    	return Integer.parseInt(txtFieldHeight.getText());
    	
    }
    
    public int getValueTxtFieldPositionX() {
    	
    	return Integer.parseInt(txtFieldPositionX.getText());
    	
    }
    
    public int getValueTxtFieldPositionY() {
    	
    	return Integer.parseInt(txtFieldPositionY.getText());
    	
    }
    
    public int getValueTxtFieldDepth() {
    	
    	return Integer.parseInt(txtFieldDepth.getText());
    	
    }
    
    public int getValueTxtFieldBorderSize() {
    	
    	return Integer.parseInt(txtFieldBorderSize.getText());
    	
    }

}
